home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacApp Release 10 / MacApp Release 10 - HD Ready / Examples / Calc / MCalc.cp < prev    next >
Encoding:
Text File  |  1996-04-03  |  3.4 KB  |  111 lines  |  [TEXT/MPS ]

  1. //----------------------------------------------------------------------------------------
  2. // MCalc.cp 
  3. // Copyright Â© 1985-96 by Apple Computer, Inc. All rights reserved.
  4. //----------------------------------------------------------------------------------------
  5.  
  6. // Calc
  7.  
  8. #ifndef __UCALC__
  9. #include "UCalc.h"
  10. #endif
  11.  
  12. // MacApp
  13.  
  14. #ifndef __UEDITIONDOCUMENT__
  15. #include "UEditionDocument.h"
  16. #endif
  17.  
  18. #ifndef __UERRORMGR__
  19. #include "UErrorMgr.h"
  20. #endif
  21.  
  22. #ifndef __UGRIDVIEW__
  23. #include "UGridView.h"
  24. #endif
  25.  
  26. #ifndef __UPRINTING__
  27. #include "UPrinting.h"
  28. #endif
  29.  
  30. #ifndef __UTEVIEW__
  31. #include "UTEView.h"
  32. #endif
  33.  
  34. // Toolbox
  35.  
  36. #ifndef __FP__
  37. #include <fp.h>
  38. #endif
  39.  
  40.  
  41. //========================================================================================
  42. // Constants
  43. //========================================================================================
  44. const    short phSplash = 1001;                         // Application's splash screen 
  45.  
  46. //========================================================================================
  47. // Global Functions
  48. //========================================================================================
  49. static TCalcApplication* InitWithSplashScreen();
  50.  
  51. //----------------------------------------------------------------------------------------
  52. // InitWithSplashScreen: Display a splash screen while doing MacApp initialization.
  53. //----------------------------------------------------------------------------------------
  54. TCalcApplication* InitWithSplashScreen()
  55. {
  56.     // To avoid heap fragmentation, we allocate space for the DialogRecord on the stack,
  57.     // as a local variable in this procedure, so that the dialog record WON'T be allocated
  58.     // as a non-relocatable block at the bottom of the heap. If we were to pass NULL to
  59.     // GetNewCenteredDialog for the dStorage, then the call to GetNewDialog would allocate
  60.     // the dialog record as a non-relocatable block at the bottom of the heap leading to
  61.     // heap fragmentation during InitUMacApp_Step3's call to MoreMasters.
  62.  
  63.     TCalcApplication*    aCalcApplication = NULL;
  64.     DialogRecord        theDialogRecord;                // allocated on the stack 
  65.  
  66.     if (GetNewCenteredDialog(phSplash, (Ptr) &theDialogRecord, (WindowRef) (-1)) != NULL)
  67.         DrawDialog((GrafPort*) &theDialogRecord);        // Show splash screen 
  68.  
  69.     // Continue with remainder of initialization 
  70.     
  71.     InitUMacApp_Step3(16);                                // Initialize memory (formerly InitUMacApp)
  72.     InitUEditionDocument();
  73.     InitUTEView();
  74.     InitUGridView(); 
  75.     InitUPrinting();
  76.  
  77.     aCalcApplication = new TCalcApplication;
  78.     aCalcApplication->ICalcApplication();
  79.     
  80.     CloseDialog((DialogRef) &theDialogRecord);            // Remember to remove the splash screen
  81.     DisposeIfHandle(theDialogRecord.items);
  82.     
  83.     return aCalcApplication;
  84.     
  85. } // InitWithSplashScreen 
  86.         
  87. //----------------------------------------------------------------------------------------
  88. // main: 
  89. //----------------------------------------------------------------------------------------
  90. #pragma push
  91. #pragma processor 68000
  92.  
  93. void main()
  94. {
  95.     InitUMacApp_Step1();                                // calls InitToolBox, ValidateConfiguration
  96.     InstallFailureHandler;                                // Install permanent outermost Failure handler
  97.                                                         // This MUST be called from main on PowerPC!
  98.  
  99.     PullApplicationToFront();                             // Pull app to front under MultiFinderâ„¢ 
  100.  
  101.     TCalcApplication* aCalcApplication = InitWithSplashScreen();
  102.     aCalcApplication->Run();
  103. } // main
  104.  
  105. #pragma pop
  106.  
  107. //----------------------------------------------------------------------------------------
  108. // End of MCalc.cp
  109.  
  110. #pragma segment Inline
  111.